package com.bitcola.security.admin.biz;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.bitcola.security.admin.mapper.ColaBannerMapper;
import com.bitcola.security.common.biz.BaseBiz;
import com.bitcola.entity.ColaAppBanner;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ColaBannerBiz extends BaseBiz<ColaBannerMapper, ColaAppBanner> {

    public List<ColaAppBanner> list(){
        return mapper.list();
    }

    public Boolean modify(ColaAppBanner banner){
        Integer k = 0;
        if(StrUtil.isEmpty( banner.getId())){
            //设置id
            banner.setId(IdUtil.fastUUID());
            k = mapper.insertSelective( banner);
        }else{
            k = mapper.updateByPrimaryKeySelective( banner);
        }
        return  k > 0;
    }

    public Boolean delete(String id){
        return mapper.deleteByPrimaryKey( id) > 0;
    }

    public ColaAppBanner findByCondition(String id){
        return mapper.findByCondition( id);
    }
}
